﻿<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />



    <link rel="stylesheet" href="../content/css/font.css">
    <link rel="stylesheet" href="../content/css/xadmin.css">
    <link rel="stylesheet" href="../content/plugin/bootstrap/css/bootstrap.min.css">
    <link rel='stylesheet' href='../content/plugin/bootstrap/css/style.css' />

    <script src="../content/js/jquery-1.10.2.min.js"></script>

    <script type="text/javascript" src="../content/js/xadmin.js"></script>
    <script type="text/javascript" src="../content/js/cookie.js"></script>
    <script src="../content/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../content/plugin/FileUpload/css/jquery.fileupload.css" />




</head>

<body>
    <div id="app">
        <div class="x-nav">

            <span class="nav-header">
                <a href="">首页</a>>
                <a href="">订单管理</a>>
                <a>
                    <cite>代理订单</cite>
                </a>
            </span>

        </div>
        <div class="x-body">
          

            <div class="layui-row">
                用户名：
                <input type="text" name="" placeholder="" v-model="search.phone" autocomplete="off"
                    style="height:30px;width: 100px;">

                订单号：
                <input type="text" name="username" placeholder="" v-model="search.order_no" autocomplete="off"
                    style="height:30px;width: 100px;">
                商品编码：
                <input type="text" name="username" placeholder="" v-model="search.goods_no" autocomplete="off"
                    style="height:30px;width: 100px;">

                状态
                <select v-model="search.order_status" style="height:30px;width: 120px;">
                    <option value="">
                        请选择
                    </option>
                    <option v-for="item in paystatelist" :value='item.id'>
                        {{item.name}}
                    </option>
                </select>

                是否支付
                <select v-model="search.pay_status" style="height:30px;width: 80px;">
                    <option value="">
                        请选择
                    </option>
                    <option v-for="item in statelist" :value='item.id'>
                        {{item.name}}
                    </option>
                </select>
                日期：
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="mydate" placeholder=" - ">

                </div>
                <button class="layui-btn" v-on:click="searchdata"><i class="layui-icon">&#xe615;</i></button>
           




            </div>
            <br/>
         
            <div class="table-responsive">
                <table id="tableExcel" class="table table-bordered table-hover">
                    <thead>
                        <tr>
                            <th style="width: 60px;" class="noExl">
                                ID</th>
                            <th class="noExl"> 店铺名称</th>
                            <th> 订单号</th>
                            <th  > 商品信息</th>

                            <th style="width: 80px;">实付款</th>
                            <th> 用户名</th>
                            <th> 头像</th>
                            <th>昵称</th>
                            <th> 收货人姓名</th>
                            <th> 收货人电话</th>
                            <th> 地址</th>
                            <th> 交易状态</th>
                            <th> 购买方式</th>
                            <th> 下单时间</th>
                            <th> 物流费用</th>
                            <th> 消费积分</th>
                            <th> 折扣</th>
                            <th> 操作</th>


                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="uitem in arrayData">
                            <td class="noExl">{{uitem.id}}</td>
                            <td>{{uitem.shopname}}</td>
                            <td>{{uitem.order_no}}</td>
                            <!-- <td>
                                <img :src="uitem.imgurl" style="width: 50px;height: 50px; object-fit: cover;
                                " />
                                {{uitem.goods_name}}
                            </td>
                            <td>{{uitem.goods_price}}/{{uitem.total_num}}</td> -->
                            <td>
                                <table class="table">
                                    <tr>
                                        <td class="noExl">
                                            图片
                                        </td>
                                        <td>
                                            名称
                                        </td>
                                        <td>
                                            单价
                                        </td>
                                        <td>
                                            数量
                                        </td>
                                        <td>
                                            编码
                                        </td>
                                        <td>
                                            规格
                                        </td>
                                    </tr>

                                    <tr v-for="item in uitem.goodlist">

                                        <td class="noExl">
                                            <img :src="item.imgurl" style="width: 50px;height: 50px; object-fit: cover;
                                            " />
                                        </td>
                                        <td>
                                            {{item.goods_name}}
                                        </td>
                                        <td style="width: 50px;">
                                            {{item.goods_price}}
                                        </td>
                                        <td>
                                            {{item.total_num}}
                                        </td>
                                        <td>
                                            {{item.goods_no}}
                                        </td>
                                        <td>
                                            {{item.goods_attr}}
                                        </td>
                                    </tr>


                                </table>


                            </td>
                            <td>
                                <template v-if="uitem.order_status==1&&check()">
                                    <input type="text" v-model="uitem.total_price" />
                                    <button class="layui-btn" @click="updateprice(uitem)">改价</button>
                                </template>

                                <span v-else>
                                    {{uitem.total_price}}
                                </span>

                            </td>
                            <td>{{uitem.phone}}</td>

                            <td>

                                <img :src="uitem.avatarurl" style="width: 50px;" />



                            </td>
                            <td>{{uitem.nickname}}</td>
                            <td>{{uitem.truename}}</td>
                            <td>{{uitem.addressphone}}</td>
                            <td>

                                <!-- {{uitem.province}}-{{uitem.city}}-{{uitem.region}} {{uitem.datail}} -->

                                <input type="text" v-if="uitem.order_status==2&&check()" @input="updateaddress(uitem)"
                                    v-model="uitem.address" />
                                <span v-else>
                                    {{uitem.province}}-{{uitem.city}}-{{uitem.region}} {{uitem.detail}}
                                </span>

                            </td>

                            <td>

                                <span v-if="uitem.order_status==1">待付款</span>
                                <span v-if="uitem.order_status==2">待发货</span>
                                <span v-if="uitem.order_status==3">待评价</span>
                                <span v-if="uitem.order_status==4">交易成功</span>
                                <span v-if="uitem.order_status==5">交易成功</span>
                            </td>


                            <td>
                                <span v-if="uitem.paytype=='WXP'">微信</span>
                                <span v-if="uitem.paytype=='ALP'">支付宝</span>
                            </td>
                            <td>{{uitem.create_time}}</td>
                            <td>{{uitem.express_price}} 日元</td>
                            <td>

                                抵扣{{uitem.xfscore}} 日元
                            </td>
                            <td>{{uitem.zhekou}}</td>
                            <td class="td-manage">

                                
                                <a v-on:click="wuliu(uitem)" v-if="uitem.order_status>2" href="javascript:;">
                                    物流信息
                                </a>
                                <a v-on:click="pingjia(uitem)" v-if="uitem.order_status==5" href="javascript:;">
                                    用户评价
                                </a>

                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="page">
                <div>
                    <vue-nav :cur="search.page" :all="all" :allcount="allcount" :callback="callback"></vue-nav>
                </div>
            </div>

        </div>




        <div class="modal fade" id="addbox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="myModal">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title" id="myModalLabel">发货</h4>
                    </div>
                    <div class="modal-body">
                        <fieldset>

                            <div class="control-group">
                                <label for="input01" class="control-label">订单号</label>
                                <div class="controls">
                                    {{addobj.order_no}}
                                </div>
                            </div>


                            <div class="control-group">
                                <label for="input01" class="control-label">物流公司</label>
                                <div class="controls">
                                    <select v-model="addobj.express_company" class="form-control">
                                        <option value="0">
                                            请选择
                                        </option>
                                        <option v-for="item in wuliulist" :value='item'>
                                            {{item}}
                                        </option>
                                    </select>
                                </div>
                            </div>


                            <div class="control-group">
                                <label for="input01" class="control-label">物流单号</label>
                                <div class="controls">
                                    <input placeholder="" type="text" class="form-control" v-model="addobj.express_no">
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="input01" class="control-label">备注</label>
                                <div class="controls">
                                    <input placeholder="" type="text" class="form-control" v-model="addobj.descs">
                                </div>
                            </div>


                        </fieldset>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" v-on:click="insert()">确认</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <div class="modal fade" id="wuliubox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="myModal">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title" id="myModalLabel">物流信息</h4>
                    </div>
                    <div class="modal-body">
                        <fieldset>

                            <div class="control-group">
                                <label for="input01" class="control-label">物流公司</label>
                                <div class="controls">
                                    {{info.express_company}}
                                </div>
                            </div>


                            <div class="control-group">
                                <label for="input01" class="control-label">物流单号</label>
                                <div class="controls">
                                    {{info.express_no}}
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="input01" class="control-label">备注</label>
                                <div class="controls">
                                    {{info.descs}}
                                </div>
                            </div>

                            <div class="control-group">
                                <label for="input01" class="control-label">详细信息</label>
                                <div class="controls">
                                    {{info.wuliu}}
                                </div>
                            </div>
                        </fieldset>

                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="pingjiabox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="myModal">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title" id="myModalLabel">用户评价</h4>
                    </div>
                    <div class="modal-body">
                        <fieldset>

                            <div class="control-group">
                                <label for="input01" class="control-label">评价内容</label>
                                <div class="controls">
                                    {{info.content}}
                                </div>
                            </div>


                            <div class="control-group">
                                <label for="input01" class="control-label">图片</label>
                                <div class="controls">
                                    <img :src="item" v-for="item in info.imglist"
                                        style="width:50px;height:50px;margin-left: 10px;" />
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="input01" class="control-label">分数汇总</label>
                                <div class="controls">
                                    综合评价 {{info.score1}}分
                                    商品描述 {{info.score2}}分
                                    物流服务 {{info.score3}}分
                                </div>
                            </div>

                            <div class="control-group">
                                <label for="input01" class="control-label">结果</label>
                                <div class="controls">
                                    {{info.type}}
                                </div>
                            </div>
                        </fieldset>

                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="viewbox" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="myModal">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        <h4 class="modal-title" id="myModalLabel">商品详情</h4>
                    </div>
                    <div class="modal-body">
                        <fieldset>
                            <table class="table">
                                <tr>
                                    <td class="noExl">
                                        图片
                                    </td>
                                    <td>
                                        名称
                                    </td>
                                    <td>
                                        单价
                                    </td>
                                    <td>
                                        数量
                                    </td>
                                </tr>

                                <tr v-for="item in info.goodlist">

                                    <td class="noExl">
                                        <img :src="item.imgurl" style="width: 50px;height: 50px; object-fit: cover;
                                        " />
                                    </td>
                                    <td>
                                        {{item.goods_name}}
                                    </td>
                                    <td>
                                        {{item.goods_price}}
                                    </td>
                                    <td>
                                        {{item.total_num}}
                                    </td>
                                </tr>


                            </table>

                        </fieldset>

                    </div>
                </div>
            </div>
        </div>




    </div>
    <link href="../content/plugin/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="../content/plugin/sweetalert/sweetalert.min.js"></script>
    <script src="../content/plugin/bootstrap/js/bootstrap.min.js"></script>
    <script src="../content/js/vue2.js"></script>
    <script src="../content/js/vue-nav.js"></script>
    <script src="../content/js/config.js"></script>





    <script>
        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#daoru'
                , url: '/upload/file' //改成您自己的上传接口
                , accept: 'file'
                , field: "imgFile"
                , before: function (obj) {

                }
                , done: function (res) {
                    //如果上传失败
                    console.log("res", res);
                    if (res.code == 200) {
                        $.post("/admin/order/importdata", { data: res.file, token: json.token }, function (data) {
                            if (data.status == 200) {
                                layer.msg("导入成功");
                                setTimeout(() => {
                                    window.location.reload();
                                }, 1000);
                            } else {
                                layer.msg(data.message);
                            }
                        })
                    } else {
                        return layer.msg('上传失败');
                    }
                    //上传成功
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    layer.msg("上传失败");
                }
            });
        });

        var timeScope;

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            timeScope = laydate.render({
                elem: '#mydate'
                , range: true
                , ready: function (date) {
                    console.log("1", date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                }
            });

        });
        Array.prototype.remove = function (val) {
            var index = this.indexOf(val);
            if (index > -1) {
                this.splice(index, 1);
            }
        };
        var vm = new Vue({
            el: "#app",
            data: {
                all: 0,
                search: {
                    page: 1,
                    size: 10,
                    mid: localStorage.getItem("mid"),
                    order_no: "",
                    truename: "",
                    stime: "",
                    etime: "",
                    pay_status: "",
                    phone: "",
                    order_status: ""
                },
                arrayData: [],
                allcount: 0,
                info: {},
                menulist: [],
                addobj: {
                    parentid: 0
                },
                editobj: {},
                datalist: [],
                statelist: [{ "id": 1, "name": "是" }, { "id": 0, "name": "否" }],
                paystatelist: [{ "id": 1, "name": "待付款" }, { "id": 2, "name": "待发货" }, { "id": 3, "name": "待收货" }, { "id": 4, "name": "待评价" }, { "id": 5, "name": "交易成功" }],
                wuliulist: [],
                order_status: "",
                paymoney: 0,
                paymoney_day: 0,
                paymoney_month: 0,
                info: {}
            },
            components: {
                'vue-nav': Vnav
            },
            filters: {
                tochina(value) {


                    return parseInt(value * parseFloat(0.061));
                },

            },
            methods: {
                downloadxls() {
                    window.open("/admin/content/xls/导入模板.xls");
                },
                importdata() {

                },
                exportExcel1() {

                    var order_no = this.search.order_no;
                    var truename = this.search.truename;
                    var pay_status = this.search.pay_status;
                    var phone = this.search.phone;
                    var order_status = this.search.order_status;

                    var stime = $("#mydate").val().split(" - ")[0];
                    var etime = $("#mydate").val().split(" - ")[1];

                    if (stime == undefined) {
                        stime = "";
                    }
                    if (etime == undefined) {
                        etime = "";
                    }
                    window.open("/admin/order/exportExcel1?order_no=" + order_no + "&truename=" + truename + "&stime=" + stime + "&etime=" + etime + "&pay_status=" + pay_status + "&phone=" + phone + "&order_status=" + order_status);



                },
                exportExcel2() {

                    var order_no = this.search.order_no;
                    var truename = this.search.truename;
                    var pay_status = this.search.pay_status;
                    var phone = this.search.phone;
                    var order_status = this.search.order_status;

                    var stime = $("#mydate").val().split(" - ")[0];
                    var etime = $("#mydate").val().split(" - ")[1];

                    if (stime == undefined) {
                        stime = "";
                    }
                    if (etime == undefined) {
                        etime = "";
                    }
                    window.open("/admin/order/exportExcel2?order_no=" + order_no + "&truename=" + truename + "&stime=" + stime + "&etime=" + etime + "&pay_status=" + pay_status + "&phone=" + phone + "&order_status=" + order_status);



                },
                exportimg() {


                    var order_no = this.search.order_no;
                    var truename = this.search.truename;
                    var pay_status = this.search.pay_status;
                    var order_status = this.search.order_status;

                    var stime = $("#mydate").val().split(" - ")[0];
                    var etime = $("#mydate").val().split(" - ")[1];

                    if (stime == undefined) {
                        stime = "";
                    }
                    if (etime == undefined) {
                        etime = "";
                    }
                    window.open("/admin/order/exportimg?order_no=" + order_no + "&truename=" + truename + "&stime=" + stime + "&etime=" + etime + "&pay_status=" + pay_status + "&order_status=" + order_status);


                },
                check() {
                    if (localStorage.getItem("mid") == "0") {
                        return true;
                    } else {
                        return false;
                    }
                },
                searchdata: function () {
                    this.search.page = 1;
                    this.getdata();
                    this.gettj();
                },


                getdata: function (_keycontent) {  //查询数据

                    var self = this;

                    var stime = $("#mydate").val().split(" - ")[0];
                    var etime = $("#mydate").val().split(" - ")[1];

                    if (stime == undefined) {
                        stime = "";
                    }
                    if (etime == undefined) {
                        etime = "";
                    }
                    this.search.stime = stime;
                    this.search.etime = etime;

               

                    $.post(apiurl + "/admin/order/list", this.search, function (_result) {
                        console.log(_result);
                        self.arrayData = _result.data;
                        self.all = _result.allcount;
                        self.allcount = _result.count;
                    });

                },
                callback: function (data) {
                    var self = this;
                    this.search.page = data;

                    var stime = $("#mydate").val().split(" - ")[0];
                    var etime = $("#mydate").val().split(" - ")[1];

                    if (stime == undefined) {
                        stime = "";
                    }
                    if (etime == undefined) {
                        etime = "";
                    }
                    this.search.stime = stime;
                    this.search.etime = etime;

                    $.post(apiurl + "/admin/order/list", this.search, function (_result) {
                        self.arrayData = _result.data;
                        self.all = _result.allcount;
                        self.allcount = _result.count;
                    });
                },
             

                vdel: function (uitem) {
                    var self = this;
                    swal({
                        title: "确定要删除吗?",
                        text: "",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "是",
                        cancelButtonText: '否',
                        closeOnConfirm: false
                    }, function () {


                        $.ajax({
                            url: apiurl + '/admin/menu/del',
                            type: 'DELETE',
                            data: { "ids": uitem.id },
                            success: function (result) {
                                if (result.status == 200) {
                                    swal("系统提示", "已删除", "success");
                                    self.getdata("");
                                } else {
                                    swal("系统提示", "系统异常", "success");
                                }
                            }
                        });

                    });
                },
                view: function (uitem) {
                    this.info = uitem;

                    $("#viewbox").modal('show');
                },
                fahuo: function (uitem) {
                    this.addobj = uitem;

                    $("#addbox").modal('show');
                },
                wuliu: function (uitem) {
                    this.info = uitem;
                    $("#wuliubox").modal('show');

                },
                updateprice(uitem) {
                    var self = this;
                    $.post(apiurl + "/admin/order/updateprice", uitem, function (_result) {
                        if (_result.status == 200) {
                            layer.msg("操作成功");
                            self.getdata();
                        }
                    });
                },
                updateaddress(uitem) {
                    var self = this;
                    $.post(apiurl + "/admin/order/updateaddress", uitem, function (_result) {
                        if (_result.status == 200) {

                        }
                    });
                },
                insert: function () {
                    var self = this;
                    $.post(apiurl + "/admin/order/fahuo", this.addobj, function (_result) {
                        if (_result.status == 200) {
                            $("#addbox").modal('hide');
                            swal("success", "操作成功", "success");
                            self.getdata("");
                        } else {
                            swal("系统提示", data.message, "error");
                        }
                    });
                },
                init: function () {

                    var self = this;
                    $.post(apiurl + "/admin/config/load", {}, function (_result) {
                        console.log(_result);
                        var info = _result.data;
                        self.wuliulist = info.wuliulist.split("/n");

                    });
                },
                pingjia(uitem) {
                    var self = this;
                    $.post(apiurl + "/admin/order/comment", { id: uitem.id }, function (_result) {
                        console.log(_result);
                        var info = _result.data;
                        info.imglist = JSON.parse(info.imglist);
                        self.info = info;
                    });


                    $("#pingjiabox").modal('show');
                }

            },
            created: function () {  //初始化事件里边去调用查询方法

                this.init();
                if (GetRequest("state")) {
                    this.search.order_status = GetRequest("state");

                }
                this.order_status = GetRequest("state");

                this.search.mid = GetRequest("mid");

                this.getdata("");
                // this.gettj();



            }
        });


    </script>
</body>

</html>